package cn.cslg.weatherforecast.design.strategy;

import android.content.Context;
import android.content.Intent;
import android.media.AudioManager;
import android.media.SoundPool;
import android.support.v7.app.AlertDialog;
import android.view.View;
import android.widget.Toast;

import cn.cslg.weatherforecast.MainActivity;
import cn.cslg.weatherforecast.R;
import cn.cslg.weatherforecast.service.MusicService;
import cn.cslg.weatherforecast.util.ServiceUtils;

public class ClickOnMusic implements Strategy {
    @Override
    public void operation(Context context) {
        Intent intent = new Intent(context, MusicService.class);
        if (!ServiceUtils.isServiceRunning(context,
                "cn.cslg.weatherforecast.service.MusicService")) {
            context.startService(intent);
            Toast.makeText(context, "开启服务", Toast.LENGTH_SHORT).show();
        } else {
            context.stopService(intent);
            Toast.makeText(context, "停止服务", Toast.LENGTH_SHORT).show();
        }

        //                if (!mediaPlayer.isPlaying()) {
        //                    mediaPlayer = MediaPlayer.create(this, R.raw.music);
        //                    mediaPlayer.setLooping(true);
        //                    mediaPlayer.start();
        //                    Toast.makeText(MainActivity.this, "开始播放", Toast.LENGTH_LONG).show();
        //                } else {
        //                    mediaPlayer.stop();
        //                    Toast.makeText(MainActivity.this, "停止播放", Toast.LENGTH_LONG).show();
        //                }
    }
}
